<?php

class Core_Model_Permission_Action extends Dcmp_Model_Entity {

    public function __construct() {
        parent::__construct();
    }

    public function validate() {
        if ($this->isNew()) {
            if ($this->getTable()->checkExists(array('code' => $this->getCode()))) {
                return array(sprintf(Kd_Localize_Helper::__f('permission.message.repeated'), '{permission.label.action}', $this->getCode()));
            }
        }
        return TRUE;
    }

    protected function initializeTable($table) {
        $table->setName('{t}permission_action');
        $table->createColumn('id', 'integer', TRUE, TRUE);
        $table->createColumn('code')->setUpdateable(FALSE);
        $table->createColumn('name');
        $table->createColumn('status')->setDefaultValue('enabled');
        $table->createColumn('group');
    }

}